
package iterators;

import java.util.*;
import IA.*;

/*Returns the waiting parties in order of the longest waiting first*/

public class LongestWaitingPartyItr implements Iterator<WaitingParty> {

    private ArrayList<WaitingParty> _Customers;
    
    public LongestWaitingPartyItr(ArrayList<WaitingParty> Customers) {
        _Customers = (ArrayList<WaitingParty>)Customers.clone();
        //sort customers by longest first
        Collections.sort(_Customers,WaitingParty.getWaitingTimeComparator());
    }
    
    @Override
    public boolean hasNext() {
        return !_Customers.isEmpty();
    }

    @Override
    public WaitingParty next() {
        return _Customers.remove(0);
    }

    @Override
    public void remove() {

    }
    
}
